const { Sequelize } = require("sequelize");
const config = require("../config/config");


const connection = new Sequelize(config.db.db, config.db.username, config.db.password, {
    host: config.db.host,
    port: config.db.port,
    dialect: "mysql",
    logging: (msg) => {
        console.log('msg', msg)
    },
    timezone: '+08:00'
})

// 测试连接
connection.authenticate().then(_ => {
    console.log("数据库连接成功!");
}).catch(err => {
    console.log("数据库连接失败! ", err);
})


module.exports = connection